<!DOCTYPE html>
<html >
<head >
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css"  media="all"/>
<link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all"/>
<link rel="stylesheet"  href="../../../css/common/loader.css" media="all"/>
<link rel="stylesheet"  href="../../../css/common/openshow.css" media="all"/>
</head>
<style>
	html{
		background-color:#fff;
		height: 100%;
    border-bottom: 2px solid #f2f2f2;
    box-sizing: border-box;
	}
	/* 上传照片样式 */
	.img-box button,.img-box .imgItem{display: inline-block;position: relative;}
	.img-box button:hover {border-color: #009688;cursor: pointer;}
	.img-box button>img,.img-box .imgItem>img{width: 140px;height: 140px;}
	.img-box button,.img-box .imgItem{
		height: 140px;
		width: 140px;
		border: 2px solid #eee;
		box-sizing: border-box;
	}
	.layui-form-pane .photo-label{height: 140px;line-height:120px;}
</style>
<body>
<form class="layui-form layui-form-pane" action="" id="saveForm">
<div class="layui-form-item">
    <label class="layui-form-label" style="width: 130px;" >タイトル</label>
    <div class="layui-input-block" style="margin-left: 130px;">
      <input type="text" name="couponTitle" lay-verify="required|max:50"     autocomplete="off"  class="layui-input">
    </div>
 </div>
 <div class="layui-form-item">
    <label class="layui-form-label layui-textarea-label" style="width: 130px;" >クーポン紹介</label>
    <div class="layui-input-block" style="margin-left: 130px;">
      <textarea name="couponSlogan" lay-verify="required|max:100"   class="layui-textarea"></textarea>
    </div>
  </div>
  <div class="layui-form-item">
 <div class="layui-inline">
    <label class="layui-form-label" style="width: 130px;" >有効期限（始）</label>
    <div class="layui-input-block" style="margin-left: 130px;">
      <input type="text" name="validBeginDate" id="validBeginDate" lay-verify="required"     autocomplete="off"  class="layui-input">
    </div>
  </div>
<div class="layui-inline">
    <label class="layui-form-label" style="width: 130px;" >有効期限（終）</label>
    <div class="layui-input-block" style="margin-left: 130px;">
      <input type="text" name="validEndDate" id="validEndDate" lay-verify="required"     autocomplete="off"  class="layui-input">
    </div>
  </div>
  </div>
 <div class="layui-form-item">
    <label class="layui-form-label layui-textarea-label" style="height:145px"  >紹介</label>
    <div class="layui-input-block">
     <textarea id="couponIntroduce" style="display: none;"></textarea>
    </div>
  </div>
		<div class="layui-form-item">
			<label class="layui-form-label layui-textarea-label photo-label"
				style="width: 130px;">写真</label>
			<div class="layui-input-block img-box">
				<div class="imgItem">
					<img id="couponImg" src="" alt="">
				</div>
				<button type="button" class="layui-btn" id="couponImageUpload">写真を追加</button>
				<input type="hidden" id="couponImage" name="couponImage" />
			</div>
		</div>
		<!-- 隐藏域 -->
   <div class="layui-form-item" style="display:none;">
    <button class="layui-btn"  lay-submit="" lay-filter="saveSubmit">提交</button>
  </div>
</form>
<script   src="../../../layuiadmin/layui/layui.js"></script>
<script type="text/javascript" src="../../../lib/jQuery-2.2.0.min.js" ></script>
	<script>
		layui.config({
			base :  '../../../layuiadmin/' //静态资源所在路径
		}).extend({
			webplus : 'lib/webplus', //主入口模块
		}).use([ 'form', 'webplus','layedit','laydate','upload' ], function() {
			var webplus = layui.webplus
			,form = layui.form
			,layedit = layui.layedit
			,laydate = layui.laydate
			,upload=layui.upload;
			//日期
			var now = new Date();
			var minDate= now.getFullYear()+"-"+(now.getMonth()+1)+"-"+now.getDate();
			laydate.render({
				elem : '#validBeginDate',
				min: minDate,
				trigger:'click'
				
			});
			//日期
			laydate.render({
				elem : '#validEndDate',
				min: minDate,
				trigger:'click'
			});
			webplus.uploadImage('couponImageUpload',{filePrefix:'C'},'couponImage','couponImg');
			
			var index =layedit.build('couponIntroduce', {
			  height: 100,
			  tool: [
				  'strong' //加粗
				  ,'italic' //斜体
				  ,'underline' //下划线
				  ,'del' //删除线
				  
				  ,'|' //分割线
				  
				  ,'left' //左对齐
				  ,'center' //居中对齐
				  ,'right' //右对齐
				  ]
			});   
			
			form.on('submit(saveSubmit)', function(data) {

				var paramData = data.field;
				var couponIntroduce=layedit.getContent(index);
				paramData.couponIntroduce=couponIntroduce;
				webplus.doAjax('buss/shopCoupon/save', paramData,'','','1');
				return false;
			});
			
		});

	</script>
</body>
</html>